<template>
  <div class="settings">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('AdvancedSetting')" left-arrow fixed @click-left="onClickLeft" />
    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
      <van-collapse class="marginTop15" v-model="activeNames">
        <van-collapse-item :title="$t('Safety')" name="1">
          <safetyVue :deviceType="3" :safety="safety" :key="timer" @getFormData="setSafety"></safetyVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('PowerFactor')" name="2">
          <van-form @submit="powerfactorSubmit">
            <van-field :value="factMode" :label="$t('ModeSelect')" readonly clickable name="picker" input-align="right" @click="showPowerFact = true" />
            <van-popup v-model="showPowerFact" round position="bottom">
              <van-picker show-toolbar :columns="powerFactors" 
                @cancel="showPowerFact = false" 
                @confirm="factModeConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')" 
              />
            </van-popup>
            <van-field v-if="factModeCode==1||factModeCode==2" 
              v-model="P2Value" 
              :label="$t('PFValue')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo1,message: `${$t('Range')}：0.80-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&safety!=21"
              v-model="P3Value" 
              :label="$t('UpperLimit')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&safety!=21"
              v-model="P4Value" 
              :label="$t('LowerLimit')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&safety!=21"
              v-model="P5Value" 
              :label="$t('PowerLow')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <van-field v-if="factModeCode==3&&safety!=21"
              v-model="P6Value" 
              :label="$t('PowerUp')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <div class="factorBtnBox">
              <van-button block round>{{$t('Save')}}</van-button>
            </div>
          </van-form>
          <pfLockInPointVue :setName="'PfLockInPoint'" :setUntil="'%'" :setMin="100" :setMax="110" :valName="'PfLockInPointValue'" :subOption="'PfLockInPoint'" :setValue.sync="PfLockInPointValue" v-if="isPFP&&safety==9"></pfLockInPointVue>
          <pfLockInPointVue :setName="'PfLockOutPoint'" :setUntil="'%'" :setMin="90" :setMax="100" :valName="'PfLockOutPointValue'" :subOption="'PfLockOutPoint'" :setValue.sync="PfLockOutPointValue" v-if="isPFP&&safety==9"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('wQuVrateUp')" :setUntil="'%'" :setMin="100" :setMax="110" :valName="'wQuVrateUpValue'" :subOption="'wQuVrateUp'" :setValue.sync="wQuVrateUpValue" v-if="isQu&&(safety==6||safety==7||safety==9)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('wQuVrateLow')" :setUntil="'%'" :setMin="90" :setMax="100" :valName="'wQuVrateLowValue'" :subOption="'wQuVrateLow'" :setValue.sync="wQuVrateLowValue" v-if="isQu&&(safety==6||safety==7||safety==9)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('SetQurangeV1')" :setUntil="'%'" :setMin="0" :setMax="60" :valName="'SetQurangeV1Value'" :subOption="'SetQurangeV1'" :setValue.sync="SetQurangeV1Value" v-if="isQu&&(safety==2||safety==19)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('SetQurangeV4')" :setUntil="'%'" :setMin="0" :setMax="60" :valName="'SetQurangeV4Value'" :subOption="'SetQurangeV4'" :setValue.sync="SetQurangeV4Value" v-if="isQu&&(safety==2||safety==19)"></pfLockInPointVue>
          <pfLockInPoint2Vue :setName="$t('bQpower_set')" :setMin="bQpowerMin" :setMax="bQpowerMax" :valName="'bQpower_setValue'" :subOption="'bQpower_set'" :setValue.sync="bQpower_setValue" v-if="isQSet&&(safety==2||safety==6||safety==7||safety==9||safety==19)"></pfLockInPoint2Vue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Grid')" name="3">
          <vacMaxVue :setName="$t('VacLower')" :setUntil="'V'" :setMin="'0.0'" :setMax="'300.0'" :valName="'VacMinValue'" :subOption="'VacMin'" :setValue.sync="VacMinValue"></vacMaxVue>
          <vacMaxVue :setName="$t('VacUpper')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :valName="'VacMaxValue'" :subOption="'VacMax'" :setValue.sync="VacMaxValue"></vacMaxVue>
          <facMaxVue :setName="$t('FacLower')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :valName="'FacMinValue'" :subOption="'FacMin'" :setValue.sync="FacMinValue"></facMaxVue>
          <facMaxVue :setName="$t('FacUpper')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :valName="'FacMaxValue'" :subOption="'FacMax'" :setValue.sync="FacMaxValue"></facMaxVue>
          <vacMaxVue :setName="$t('Vac10MAvg')" :setUntil="'V'" :setMin="'150.0'" :setMax="'300.0'" :valName="'Grid10MinAverageValue'" :subOption="'Grid10MinAverage'" :setValue.sync="Grid10MinAverageValue" v-if="safety!=0&&safety!=3&&safety!=8&&safety!=10&&safety!=13&&safety!=14&&safety!=20"></vacMaxVue>
          <vacMaxVue :setName="$t('VacLowerSlow')" :setUntil="'V'" :setMin="'0.0'" :setMax="'300.0'" :valName="'VacMinSlowProtectValue'" :subOption="'VacMinSlowProtect'" :setValue.sync="VacMinSlowProtectValue"></vacMaxVue>
          <vacMaxVue :setName="$t('VacUpperSlow')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :valName="'VacMaxSlowProtectValue'" :subOption="'VacMaxSlowProtect'" :setValue.sync="VacMaxSlowProtectValue"></vacMaxVue>
          <facMaxVue :setName="$t('FacLowerSlow')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :valName="'FacMinSlowProtectValue'" :subOption="'FacMinSlowProtect'" :setValue.sync="FacMinSlowProtectValue"></facMaxVue>
          <facMaxVue :setName="$t('FacUpperSlow')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'65.00'" :valName="'FacMaxSlowProtectValue'" :subOption="'FacMaxSlowProtect'" :setValue.sync="FacMaxSlowProtectValue"></facMaxVue>
          <facMaxVue :setName="$t('wFreqSetPoint')" :setUntil="'Hz'" :setMin="'50.20'" :setMax="'51.00'" :valName="'wFreqSetPointValue'" :subOption="'wFreqSetPoint'" :setValue.sync="wFreqSetPointValue" v-if="safety==6||safety==7"></facMaxVue>
          <pfLockInPointVue :setName="$t('wFreqDroopRate')" :setUntil="'%'" :setMin="2" :setMax="12" :valName="'wFreqDroopRateValue'" :subOption="'wFreqDroopRate'" :setValue.sync="wFreqDroopRateValue" v-if="safety==6||safety==7"></pfLockInPointVue>
          <freDroopDelayTimeVue :setName="'wFreDroopDelayTime'" :setUntil="'Ms'" :setMin="0" :setMax="1000" :valName="'wFreDroopDelayTimeValue'" :subOption="'wFreDroopDelayTime'" :setValue.sync="wFreDroopDelayTimeValue" v-if="safety==9"></freDroopDelayTimeVue>
          <timeVacMinFastAdjVue :setName="'TuvpFast'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeVacMinFastAdjValue'" :subOption="'TimeVacMinFastAdj'" :setValue.sync="TimeVacMinFastAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TovpFast'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeVacMaxFastAdjValue'" :subOption="'TimeVacMaxFastAdj'" :setValue.sync="TimeVacMaxFastAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TufpFast'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeFacMinFastAdjValue'" :subOption="'TimeFacMinFastAdj'" :setValue.sync="TimeFacMinFastAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TofpFast'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeFacMaxFastAdjValue'" :subOption="'TimeFacMaxFastAdj'" :setValue.sync="TimeFacMaxFastAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TuvpSlow'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeVacMinSlowAdjValue'" :subOption="'TimeVacMinSlowAdj'" :setValue.sync="TimeVacMinSlowAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TovpSlow'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeVacMaxSlowAdjValue'" :subOption="'TimeVacMaxSlowAdj'" :setValue.sync="TimeVacMaxSlowAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TufpSlow'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeFacMinSlowAdjValue'" :subOption="'TimeFacMinSlowAdj'" :setValue.sync="TimeFacMinSlowAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <timeVacMinFastAdjVue :setName="'TofpSlow'" :setUntil="'Ms'" :setMin="1" :setMax="9999" :valName="'TimeFacMaxSlowAdjValue'" :subOption="'TimeFacMaxSlowAdj'" :setValue.sync="TimeFacMaxSlowAdjValue" v-if="safety==9"></timeVacMinFastAdjVue>
          <setOFLimitVue :setName="$t('UFPL_StartPoint')" :setUntil="'Hz'" :setMin="'47.00'" :setMax="'49.90'" :subOption="'UFPL_StartPoint'" :setValue.sync="ufplStartPointValue" v-if="safety==9"></setOFLimitVue>
          <setOFLimitVue :setName="$t('OFPL_StartPoint')" :setUntil="'Hz'" :setMin="'50.10'" :setMax="'52.00'" :subOption="'OFPL_StartPoint'" :setValue.sync="ofplStartPointValue" v-if="safety==9"></setOFLimitVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Charger')" name="4" v-if="isLeadAcid">
          <pfLockInPointVue :setName="$t('MinCapacity')" :setUntil="'%'" :setMin="5" :setMax="100" :valName="'BatteryMinEnergyValue'" :subOption="'BatteryMinEnergy'" :setValue.sync="BatteryMinEnergyValue"></pfLockInPointVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('H/LVRTFunction')" name="5">
          <enablepublicVue :subOption="'H/LVRT'" :columns="toggleArr" :setValue="LocalArr.HLVRTFunctionValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ExportControl')" name="6">
          <pfLockInPointVue :setName="$t('UserValue')" :setUntil="'W'" :setMin="0" :setMax="60000" :valName="'ExportLimitValue'" :subOption="'ExportLimit'" :setValue.sync="ExportLimitValue"></pfLockInPointVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('puFunction')" name="7" v-if="safety==2||safety==19">
          <enablepublicVue
            :setName="$t('puFunction')"
            :columns="toggleArr"
            :setValue="LocalArr.puFunctionEnableCode"
            :subOption="'puFunction'"
            @getFormData="setPuFunction"
          ></enablepublicVue>
          <vacMaxVue :setName="$t('SetV2')" :setUntil="'V'" :setMin="'216.0'" :setMax="'230.0'" :valName="'SetV2Value'" :setValue.sync="SetV2Value" :subOption="'SetV2'" v-if="isPu"></vacMaxVue>
          <vacMaxVue :setName="$t('SetV3')" :setUntil="'V'" :setMin="'235.0'" :setMax="'255.0'" :valName="'SetV3Value'" :setValue.sync="SetV3Value" :subOption="'SetV3'" v-if="isPu"></vacMaxVue>
          <vacMaxVue :setName="$t('SetV4')" :setUntil="'V'" :setMin="'244.0'" :setMax="'265.0'" :valName="'SetV4Value'" :setValue.sync="SetV4Value" :subOption="'SetV4'" v-if="isPu"></vacMaxVue>
        </van-collapse-item>
        <van-collapse-item title="DRM Function" name="8" v-if="safety==2||safety==19">
          <enablepublicVue :subOption="'wAS4777PowerManagerEnable'" :columns="toggleArr" :setValue="LocalArr.DRMFunctionValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('SetWgra')" name="9" v-if="safety==2||safety==19">
          <facMaxVue :setName="$t('SetWgra')" :setUntil="'%'" :setMin="'5.00'" :setMax="'100.00'" :valName="'SetWgraValue'" :subOption="'SetWgra'" :setValue.sync="SetWgraValue"></facMaxVue>
        </van-collapse-item>
        <van-collapse-item title="GlblMPPT Function" name="10">
          <enablepublicVue :subOption="'wGlobalMPPTFuncEnable'" :columns="toggleArr" :setValue="LocalArr.GlobalMPPTFuncEnableValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ParallelSetting')" name="11">
          <enablepublicVue :subOption="'ParallelSetting'" :columns="parallelArr" :setValue="LocalArr.ParalleSettinglValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('GridService')" name="12" v-if="safety==9">
          <enablepublicVue :subOption="'GridService'" :columns="toggleArr" :setValue="LocalArr.GridServiceValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('BatteryAwaken')" name="13">
          <languageVue :columns="toggleArr" :valName="'BatAwakenValue'" :subOption="'BatAwaken'" :setValue="LocalArr.BatAwakenValue"></languageVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Reset')" name="14">
          <resetINVEnergyVue :setName="$t('ClearInverterHistory')" :valName="'ClearInverterHistoryValue'" :subOption="'ClearInverterHistory'"></resetINVEnergyVue>
          <resetErrorLogsVue :setName="$t('ResetErrorLogs')" :subOption="'ResetErrorLog'"></resetErrorLogsVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('NewPassword')" name="15">
          <newPasswordVue :valName="'NewPasswordValue'" :subOption="'NewPassword'" :setValue.sync="NewPasswordValue"></newPasswordVue>
        </van-collapse-item>
      </van-collapse>
    </van-pull-refresh>
  </div>
</template>

<script>
import safetyVue from '../../../components/Safety/BDSafety'
import pfLockInPointVue from '../../../components/PfLockInPoint/BDPfLockInPoint'
import vacMaxVue from '../../../components/VacMax/BDVacMax'
import enablepublicVue from '../../../components/EnablePublic/BDEnablePublic'
import facMaxVue from '../../../components/FacMax/BDFacMax'
import resetINVEnergyVue from '../../../components/ResetINVEnergy/BDResetINVEnergy'
import resetErrorLogsVue from '../../../components/ResetErrorLogs/BDResetErrorLogs'
import newPasswordVue from '../../../components/NewPassword/BDNewPassword'
import freDroopDelayTimeVue from '../../../components/FreDroopDelayTime/BDFreDroopDelayTime'
import timeVacMinFastAdjVue from '../../../components/TimeVacMinFastAdj/BDTimeVacMinFastAdj'
import setOFLimitVue from '../../../components/SetOFLimit/BDSetOFLimit'
import languageVue from '../../../components/Language/BDLanguage'
import pfLockInPoint2Vue from '../../../components/PfLockInPoint/BDPfLockInPoint2'

export default {
  components:{
    safetyVue,
    pfLockInPointVue,
    vacMaxVue,
    enablepublicVue,
    facMaxVue,
    resetINVEnergyVue,
    resetErrorLogsVue,
    newPasswordVue,
    freDroopDelayTimeVue,
    timeVacMinFastAdjVue,
    setOFLimitVue,
    languageVue,
    pfLockInPoint2Vue
  },
  data(){
    return {
      isLoading:false,
      timer:'',
      activeNames:[],
      safety:sessionStorage.getItem('safety'),
      showPowerFact:false,
      factorArr:[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}],
      powerFactors:[],
      factMode:'',
      factModeCode:'',
      isPFP:true,
      isQu:true,
      isQSet:true,
      P2Value:'',
      P3Value:'',
      P4Value:'',
      P5Value:'',
      P6Value:'',
      PfLockInPointValue:'',
      PfLockOutPointValue:'',
      wQuVrateUpValue:'',
      wQuVrateLowValue:'',
      SetQurangeV1Value:'',
      SetQurangeV4Value:'',
      bQpower_setValue:'',
      bQpowerMin:'',
      bQpowerMax:'',
      VacMinValue:'',
      VacMaxValue:'',
      FacMinValue:'',
      FacMaxValue:'',
      Grid10MinAverageValue:'',
      VacMinSlowProtectValue:'',
      VacMaxSlowProtectValue:'',
      FacMinSlowProtectValue:'',
      FacMaxSlowProtectValue:'',
      wFreqSetPointValue:'',
      wFreqDroopRateValue:'',
      wFreDroopDelayTimeValue:'',
      TimeVacMinFastAdjValue:'',
      TimeVacMaxFastAdjValue:'',
      TimeFacMinFastAdjValue:'',
      TimeFacMaxFastAdjValue:'',
      TimeVacMinSlowAdjValue:'',
      TimeVacMaxSlowAdjValue:'',
      TimeFacMinSlowAdjValue:'',
      TimeFacMaxSlowAdjValue:'',
      ufplStartPointValue:'',
      ofplStartPointValue:'',
      toggleArr:[this.$t('Disable'),this.$t('Enable')],
      ExportLimitValue:'',
      isPu:false,
      SetV2Value:'',
      SetV3Value:'',
      SetV4Value:'',
      SetWgraValue:'',
      parallelArr:['Free','Master'],
      NewPasswordValue:'',
      BatteryMinEnergyValue:'',
      isLeadAcid:false,
      LocalArr:{
        HLVRTFunctionValue:'',
        puFunctionEnableCode:'',
        DRMFunctionValue:'',
        GlobalMPPTFuncEnableValue:'',
        ParalleSettinglValue:'',
        GridServiceValue:'',
        BatAwakenValue:''
      }
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/bdsetting'});
    },
    factModeConfirm(value,i){
      this.showPowerFact=false;
      this.factMode=value.text;
      this.factModeCode=value.code;
    },
    fixedTwo1(val){
      return this.comm.fixedTwo(val,0.8,1);
    },
    fixedTwo2(val){
      return this.comm.fixedTwo(val,0.9,1);
    },
    fixedTwo3(val){
      return this.comm.fixedTwo(val,0,1);
    },
    async getData(){
      this.comm.loadingShow();
      let datas=await this.SETAPI.LocalIn({'optType':'ReadSetData','pwd':sessionStorage.getItem('bdPwd')});
      if(datas!=null||datas!=undefined){
        let dataArr = datas;
        this.safety=dataArr[4];
        sessionStorage.setItem('safety',this.safety);
        this.factModeCode=dataArr[13];
        this.factMode=this.factorArr[this.factModeCode].text;
        /*判断用户的选择*/
        if(dataArr[13]==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(dataArr[13]==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(dataArr[13]==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
        this.P2Value=dataArr[14];
        this.P3Value=dataArr[15];
        this.P4Value=dataArr[16];
        this.P5Value=dataArr[17];
        this.P6Value=dataArr[18];
        this.PfLockInPointValue=dataArr[96];
        this.PfLockOutPointValue=dataArr[97];
        this.wQuVrateUpValue=dataArr[102];
        this.wQuVrateLowValue=dataArr[103];
        this.SetQurangeV1Value=dataArr[129];
        this.SetQurangeV4Value=dataArr[130];
        this.bQpower_setValue=dataArr[132];
        this.bQpowerMin=dataArr[134];
        this.bQpowerMax=dataArr[133];
        this.VacMinValue=dataArr[0];
        this.VacMaxValue=dataArr[1];
        this.FacMinValue=dataArr[2];
        this.FacMaxValue=dataArr[3];
        this.Grid10MinAverageValue=dataArr[6];
        this.VacMinSlowProtectValue=dataArr[7];
        this.VacMaxSlowProtectValue=dataArr[8];
        this.FacMinSlowProtectValue=dataArr[9];
        this.FacMaxSlowProtectValue=dataArr[10];
        this.wFreqSetPointValue=dataArr[99];
        this.wFreqDroopRateValue=dataArr[100];
        this.wFreDroopDelayTimeValue=dataArr[101];
        this.TimeVacMinFastAdjValue=dataArr[69];
        this.TimeVacMaxFastAdjValue=dataArr[70];
        this.TimeFacMinFastAdjValue=dataArr[71];
        this.TimeFacMaxFastAdjValue=dataArr[72];
        this.TimeVacMinSlowAdjValue=dataArr[73];
        this.TimeVacMaxSlowAdjValue=dataArr[74];
        this.TimeFacMinSlowAdjValue=dataArr[75];
        this.TimeFacMaxSlowAdjValue=dataArr[76];
        this.ufplStartPointValue=dataArr[161];
        this.ofplStartPointValue=dataArr[162];
        this.LocalArr.HLVRTFunctionValue=dataArr[170];
        this.ExportLimitValue=dataArr[63];
        this.LocalArr.puFunctionEnableCode=dataArr[131];
        /*判断用户的选择*/
        if(this.LocalArr.puFunctionEnableCode==1){
          this.isPu=true;
        }else{
          this.isPu=false;
        }
        this.SetV2Value=dataArr[126];
        this.SetV3Value=dataArr[127];
        this.SetV4Value=dataArr[128];
        this.LocalArr.DRMFunctionValue=dataArr[140];
        this.SetWgraValue=dataArr[125];
        this.LocalArr.GlobalMPPTFuncEnableValue=dataArr[142];
        this.LocalArr.ParalleSettinglValue=dataArr[150];
        this.LocalArr.GridServiceValue=dataArr[143];
        this.LocalArr.BatAwakenValue=dataArr[95];
        this.NewPasswordValue=this.comm.showPwd(dataArr[104]);
        //判断铅酸电池
        if(dataArr[32]==1){
          this.isLeadAcid=true;
        }else{
          this.isLeadAcid=false;
        }
        this.BatteryMinEnergyValue=dataArr[31];
      }else{
        this.comm.tipsShow('InvNoResponse');
      }
    },
    //获取powerfactor列表
    getPowerFactory(){
      if(this.safety==2||this.safety==6||this.safety==7||this.safety==9||this.safety==19){
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}];
      }else if(this.safety==21){
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2}];
      }else{
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited1'),code:1},{text:this.$t('UnderExcited1'),code:2},{text:this.$t('PF(P)'),code:3}];
      }
    },
    //设置安规
    setSafety(data){
      if(data=='success'){
        this.safety=sessionStorage.getItem('safety');
        this.getPowerFactory();
      }
    },
    //设置powerfactor
    async powerfactorSubmit(){
      //处理数据
      let factorData_new={};
      factorData_new.optType="PowerFactor";
      factorData_new.pwd=sessionStorage.getItem('bdPwd');
      factorData_new.P1Value=this.factModeCode;
      if(this.P2Value!=null&&this.P2Value!=undefined){
        factorData_new.P2Value=this.comm.mulFunction(this.P2Value,100);
      }
      if(this.P3Value!=null&&this.P3Value!=undefined){
        factorData_new.P3Value=this.comm.mulFunction(this.P3Value,100);
      }
      if(this.P4Value!=null&&this.P4Value!=undefined){
        factorData_new.P4Value=this.comm.mulFunction(this.P4Value,100);
      }
      if(this.P5Value!=null&&this.P5Value!=undefined){
        factorData_new.P5Value=this.comm.mulFunction(this.P5Value,100);
      }
      if(this.P6Value!=null&&this.P6Value!=undefined){
        factorData_new.P6Value=this.comm.mulFunction(this.P6Value,100);
      }
      this.comm.loadingShow();
      let data = await this.SETAPI.LocalIn(factorData_new);
      let newdata = data.substring(0,1);
      if (newdata == "Y") {
        this.comm.toastSuccess();
        /*判断用户的选择*/
        if(this.factModeCode==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(this.factModeCode==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(this.factModeCode==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
      }else{
        this.comm.toastFail();
      }
    },
    //设置PU Function
    setPuFunction(data){
      /*判断用户的选择*/
      if (data == 1) {
        this.isPu = true;
      } else {
        this.isPu = false;
      }
    },
    onRefresh(){
      this.isLoading = false;
      this.timer=new Date().getTime();
      for(let i in this.LocalArr){
        this.LocalArr[i]='';
      }
      this.getData();
      this.getPowerFactory();
    }
  },
  mounted(){
    setTimeout(()=>{
      this.getData();
      this.getPowerFactory();
    },1000);
  }
}
</script>

<style scoped lang="less">

</style>
